package com.atguigu.gulimall.product.web;

import com.atguigu.gulimall.product.entity.vo.SkuItemVo;
import com.atguigu.gulimall.product.service.SkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ItemController {

    @Autowired
    private SkuInfoService skuInfoService;

    @RequestMapping("/{skuId}.html")
    public String ItemPage(@PathVariable("skuId") Long skuId, Model model){
        SkuItemVo skuItemVo=  skuInfoService.skuInfo(skuId);
        model.addAttribute("item",skuItemVo);
        return "item2";
    }
    @ResponseBody
    @RequestMapping("/testPage/{skuId}")
    public SkuItemVo TestPage(@PathVariable("skuId") Long skuId){
        SkuItemVo skuItemVo=  skuInfoService.skuInfo(skuId);
        return skuItemVo;
    }

}
